package com.cloudpark.common.util;

import java.util.Date;
import java.util.UUID;

public class UuidUtil {

	private static long num = 0;

	/**
	 * 获得一个UUID
	 * 
	 * @return String UUID
	 */
	public static synchronized String getUUID() {
		String uuid = UUID.randomUUID().toString();
		// 去掉“-”符号
		// return uuid.replaceAll("-", "");
		return uuid;
	}

	public static synchronized String getTCOrderNo() {
		String time = DateUtils.toString(new Date(), "yyyyMMddHHmmssS");
		System.out.println("原始id=" + time);
		if (num >= 99)
			num = 0l;
		++num;
		if (num < 10) {
			time = time + 00 + num;
		} else {
			time += num;
		}
		return "TC"+time;
	}
	
	public static synchronized String getYKOrderNo() {
		String time = DateUtils.toString(new Date(), "yyyyMMddHHmmssS");
		System.out.println("原始id=" + time);
		if (num >= 99)
			num = 0l;
		++num;
		if (num < 10) {
			time = time + 00 + num;
		} else {
			time += num;
		}
		return "YK"+time;
	}

	public static void main(String[] args) {
		System.out.println(getUUID());
		System.out.println(getTCOrderNo());
		System.out.println(getYKOrderNo());
	}
}
